<link type="text/css" rel="stylesheet" href="/js/plugins/dropdown/style.css"></link>
<script type="text/javascript" src="/js/plugins/dropdown/dropdown.js"></script>
<script type="text/javascript">
$(document).ready(function() {

	<?foreach( $this->contents as $u ):?>
	$("#accountDropdown-<?=$u['id']?>").dropDownList('dropdown-<?=$u['id']?>','accountValue<?=$u['id']?>','accountList<?=$u['id']?>');
    <?endforeach;?>

	$("#changeState").change(function (){
		window.location = "/admin/order/filter/status/"+$(this).val();
	});
	
	$('.listProducts').click(function() 
	{
		var id = $(this).attr('rel');
		$('#dialog').dialog('open');
		$.get("/admin/order/products/id/"+id,function(data)
		{
			$('#dialog').html(data);
		}); 
	});
	
	$("#dialog").dialog({
		bgiframe: true,
		autoOpen: false,
		width: 430,
		modal: true,
		title : 'Productos del pedido',
		buttons: {
				'Cerrar': function() {
				$(this).dialog('close');
			}
		},	
	
	});
	
	$("#list")
	.tablesorter({widthFixed: true, widgets: ['zebra'],headers: {0: {sorter: false }, 5: {sorter: false}}})
	.tablesorterPager({container: $("#pager")});  
	
});	

</script>
<input type="hidden" id="orderValue" value="" >
<div id="dialog">
	<br/><br/>
	<p>Est&aacute; seguro que desea eliminar el Pedido?</p>
</div>

       		
                <!-- h2 stays for breadcrumbs -->
                <h2><a href="#">Pedidos</a> &raquo; <a href="#" class="active">Listar pedidos</a></h2>
                
                <div id="main">
					<h3><a href="/admin/order">Raiz</a> &raquo; <?=$this->categoryName ?></h3>
					<div style="margin-bottom: 10px;" id="buttonAdd">
    				Estado:
    				<select id="changeState">
    					<option value="">-- --</option>
    			    	<option value="En espera">En espera</option>
    			    	<option value="Pagado">Pagado</option>
    			    	<option value="Rechazado">Rechazado</option>
    			    	<option value="Aceptado">Aceptado</option>
    			    </select> 
    				</div>
					<table cellpadding="0" cellspacing="0" id="list" class="tablesorter">
						<thead>
						<tr>
							<th style="width : 5%;"></th>
							<th>Fecha</th>
							<th># de Pedido</th>
							<th>Estado</th>
							<th>Cliente</th>
							<th>Importe</th>
							<th></th>
						</tr>	
						</thead>
						<tbody>
							 <? $i = 0;?>
							       <?if ( count($this->contents) == 0 ):?>
      									<tr></tr>
      							   <?endif;?>
      							   	
      							<?foreach( $this->contents as $u ):?>
      							<?
      								if ( $i%2  == 1 )
      								{
      									$class = "odd";
      								} 
      								else
      								{
      									$class = "";
      								}	
      								$i++;
      							?>  
      						<tr class="<?=$class ?>">
								<td><img style="vertical-align : middle;" src="/images/icons/page_white.png" /></td>
                                <td ><a  href="#"><?=substr($u['date'],0,10)?></a></td>
                                <td ><a  href="#"><?=$u['id']?></a></td>
                                <td>
                                <div class="changeState accountDropdown-<?=$u['id']?>">
          							<dl id="accountList<?=$u['id']?>" class="dropdownStateSelect dropdown-<?=$u['id']?>">	
        								<dt><a href="#"><span><img src="/images/<?=$u['status'] ?>.png"/>&nbsp;<?=$u['status']?></span></a></dt>
	        							<dd>
    	        							<ul style="z-index : 1001" > 
       	         								<li><a href="#"><img src="/images/En espera.png" >&nbsp;<span class="">En espera</span><span class="value">En espera</span></a></li>
       	         								<li><a href="#"><img src="/images/Pagado.png" >&nbsp;<span class="">Pagado</span><span class="value">Pagado</span></a></li>
       	         								<li><a href="#"><img src="/images/Rechazado.png" >&nbsp;<span class="">Rechazado</span><span class="value">Rechazado</span></a></li>
       	         								<li><a href="#"><img src="/images/Aceptado.png" >&nbsp;<span class="">Aceptado</span><span class="value">Aceptado</span></a></li>
       	         								
       	     								</ul>
	     								</dd>
   		 							</dl>
    								<span id="accountValue<?=$u['id']?>" rel="<?=$u['id']?>"></span>
								</div>
                                </td>
                                <td>
                                	<a href="#">
                                	<?$client = new Zend_Models_Client();?>
                                	<?$client = $client->getClientById($u['id_client']);?>
                                	<?=$client['name']." ".$client['last_name']?>
                                	</a>
                                </td>
                                <td><a href="#">
                                	  <?$currency = new Zend_Models_Currency();?>
                                	  <?$currency = $currency->getCurrencyById($u['currency']) ?>	
                                      <?=$currency->symbol ?><?=$u['total_price']?>
                                	</a></td>
                                <td class="action"><a rel="<?=$u['id']?>" title="Listado de productos" href="#"  class="listProducts edit"><img src="/images/icons/cart.png" style="vertical-align : middle;" alt="edit"  border=0 /></a></td>
                            </tr>       
                            <?endforeach?>                  
						</tbody>	                        
                        </table>
                        <div id="pager" class="pager">
						<form>
							<a href="#" class="first"><img border=0 src="/img/iomanager/icons/go-first.png" /></a>
							<a href="#" class="prev"><img border=0  src="/img/iomanager/icons/go-previous.png" /></a>
							<span class="pagedisplay"></span>
							<a href="#" class="next"><img border=0 src="/img/iomanager/icons/go-next.png" /></a>
							<a href="#" class="last"><img border=0  src="/img/iomanager/icons/go-last.png" /></a>
							<select class="pagesize">
								<option selected="selected"  value="10">10</option>
								<option value="20">20</option>
								<option value="50">50</option>
								<option  value="100">100</option>
							</select>
						</form>
						</div>
					
                </div>
                <!-- // #main -->
                
                <div class="clear"></div>
  
